<script src="/js/contentflow.js" type="text/javascript"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="/js/google_map.js" type="text/javascript"></script>
<script type="text/javascript">

var ajax_cf = new ContentFlow('ajax_cf');

function addPictures(t){
		
		//On récupere le nombre d'image qu'il y a avant l'ajout 
		var nb= ajax_cf.getNumberOfItems();
		var k=0;
		//On ajoute les éléments de la salle dont on a besoin
        //On efface les images de la salle pr�c�demment visit�e
        for (k=1;k<=nb;k=k+1){
			var res= ajax_cf.rmItem([k]);
		}
        var ic = document.getElementById('itemcontainer');
        var is = ic.getElementsByTagName('img');
        for (var i=0; i< is.length; i++) {
            ajax_cf.addItem(is[i], 'last');
        }
        ajax_cf.resize();
        //On efface les images de la salle précédemment visitée
//        for (k=1;k<=nb;k=k+1){
		//	var res= ajax_cf.rmItem([k]);
	//	}
}

function getPictures(n) { // Supprimer cette fonction et utiliser showRoom
	showRoom(n); 
	return false;
}

</script>

	
	
<div id="visit">
	<div id="content">
		<div id="rooms">
		</div>
		<h2>Oeuvres</h2>
		<div id="pieces">
	<!-- Ici commence le coverflow -->	
		
		<form  style= 'visibility:hidden'method="get" onsubmit="return getPictures(document.getElementById('pics').value)">
   		 <div style="margin: 0 0 0 0">
        <!-- Ajouter les images de la sale <input id="pics" type="text" value="1" size="2"/> � la gallerie.-->
        <SELECT id="pics"   name="salle">
	<?php $i=1?>	
		<?php foreach($query_room->result() as $row){?>
	
		<OPTION VALUE="<?php echo $row->id;?>">Salle <?php echo $row->name;?></OPTION>
		
    		<?php 
    			$i=$i+1;
			}
		?>
	</SELECT>
        <input type="submit" value="ok"/>
    </div>
</form>

<div id="ajax_cf" class="ContentFlow">
    <div class="flow"></div>
    <div class="scrollbar" style='background-color:grey'><div class="slider" style='background-color:green'><div class="position"></div></div></div>
</div>
<div id="itemcontainer" style="height: 0px; width: 0px; visibility: hidden"></div>
		
		<!-- Ici fin du coverflow -->
		
		</div>
	</div>
	<div id="sidebar">
		<div id="piece">...</div>
		
		
		
		
		<div id="comments">...</div>
	<div><?php echo $this->load->view('social_view');?></div>
	</div>
</div>
<script type="text/javascript">

$(document).ready(function() {
	showPiece(<?php echo $piece_id;?>);
	showGrid(<?php echo $piece_id;?>);
	});

function showGrid(piece_id){
	$('#rooms').load('/index.php/expositions/view/'+piece_id, function(){});
}
function showRoom(room_id){
	$('#itemcontainer').load('/index.php/coverflow/photo_salle/'+room_id, function() {
		addPictures();
	}
	);
	return false;
}

function showMap(id){
	$('#pieces').load('recherche_expo/adress_user/'+id, function() {
});
}

function showPiece(piece_id){
	$('#piece').load('/index.php/pieces/view/'+piece_id, function() {});
	$('#comments').load('/index.php/comments/get/'+piece_id, function() {});
}

function jaime(piece_id){
	$('#piece').load('/index.php/like/do_like/'+piece_id, function() {});
	alert("moi aussi j'aime!");
}

function showTop(){
	$('#top').load('/index.php/statistic/top', function() {});
}
</script>

